<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="i1" placeholder="请输入1-100之间的数">
<input type="button" style="height: 20px;width: 50px;" value="猜一猜">
<div></div>


<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script>
    //jq版本
    let x = parseInt(Math.random()*100)+1;
    let times=0;
    $("input:eq(1)").click(function () {
        times+=1;
        let num = $("input:eq(0)").val();
        if(num==x){
            $("div").text("恭喜您,在第"+times+"次猜对了!");
        }else if(num<x){
            $("div").text("猜小了!");
        }else{
            $("div").text("猜大了!");
        }
    })
</script>
</body>
</html>